#pragma once
#include<iostream>
#include<mysql_driver.h>
#include<mysql_connection.h>
#include<cppconn/statement.h>
#include<cppconn/resultset.h>
#include<cppconn/prepared_statement.h>
#include<cppconn/exception.h>
#include"public.h"
using namespace std;
using namespace sql::mysql;
using namespace sql;
class Connect
{
public:

    Connect(string url,string username,string passwd,string dbname);
    ~Connect();

    Connection* getConnection();

    // 刷新一下连接的起始的空闲时间点
	void refreshAliveTime() { _alivetime = clock(); }
	// 返回存活的时间
	clock_t getAliveeTime()const { return clock() - _alivetime; }
private:
    Connection *m_conn;
    clock_t _alivetime;
    MySQL_Driver *driver;
};